$(document).ready(function() {

	$(".good-image-top").mousemove(function(event) {
		event = event || window.event;
		$("#slider_block").show();
		$("#big_image").css("display", "inline-block");

		var disX = event.pageX - $("#slider_block").get(0).offsetWidth / 2 - $(".good-image-top").offset().left;
		var disY = event.pageY - $("#slider_block").get(0).offsetHeight / 2 - $(".good-image-top").offset().top;

		var distenceMaxX = $(".good-image-top").get(0).offsetWidth - $("#slider_block").get(0).offsetWidth;
		var distenceMaxY = $(".good-image-top").get(0).offsetHeight - $("#slider_block").get(0).offsetHeight;

		var distenceMinX = 0;
		var distenceMinY = 0;

		if(disX < distenceMinX) {
			disX = distenceMinX;
		} else if(disX >= distenceMaxX) {
			disX = distenceMaxX
		}
		if(disY < distenceMinY) {
			disY = distenceMinY;
		} else if(disY >= distenceMaxY) {
			disY = distenceMaxY;
		}

		$("#slider_block").css("left", disX + "px");
		$("#slider_block").css("top", disY + "px");

		// 3、通过计算sliderblock在littleImage的比例，计算bigImage在大图中显示的比例
		var scaleX = disX / distenceMaxX;
		var scaleY = disY / distenceMaxY;

		var sleft = $("#images").get(0).offsetWidth - $("#big_image").get(0).offsetWidth;
		var stop = $("#images").get(0).offsetHeight - $("#big_image").get(0).offsetHeight;

		$("#big_image").scrollLeft(sleft * scaleX);
		$("#big_image").scrollTop(stop * scaleY);
	});

	//添加鼠标移出事件
	$(".good-image-top").mouseleave(function() {
		$("#slider_block").hide(); //  slrBlock隐藏
		$("#big_image").hide(); //  bigImage隐藏
	});
});